"""
File: 2.py
Project: 基础部分
File Created: 2020/02/10 16:31:11
Author: Dunmore (fovd2020@outlook.com)
------------------------------------------------------------------
Description:1.1.1活动2-思考与练习-基础部分2
利用词云展示英语单词的听写情况
输入听写错误的单词，利用wordcloud库形象化地展示
------------------------------------------------------------------
"""
import os
from wordcloud import WordCloud

currrent_dir = (
    os.path.dirname(__file__) if "__file__" in locals() else os.getcwd()
)

wrong_words = open(
    os.path.join(currrent_dir, "wrong_words.txt"), "r", encoding="utf-8"
).read()

word_cloud = WordCloud().generate(wrong_words)

# 生成图片展示，需要Pillow
image = word_cloud.to_image()
image.show()
